import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { ProductComponent } from './product/product.component';
import { Code404Component } from './code404/code404.component';
import { ProductDesComponent } from './product-des/product-des.component';
import { SellerComponent } from './seller/seller.component';
import { ChatComponent } from './chat/chat.component';
import { LoginGuard } from './gurd/login.gurd';
import { UnsavedGuard } from './gurd/unsaved.gurd';
import { ProductResolve } from './gurd/product.resolve';
const routes: Routes = [
  {path:'',redirectTo:'/home',pathMatch:'full'},
  {path:'home',component:HomeComponent},
  {path:'chat',component:ChatComponent,outlet:'aux'},
  // {path:'product',component:ProductComponent},
  {
    path:'product/:id',component:ProductComponent,
    children:[
      {path:'',component:ProductDesComponent},
      {path:'seller/:id',component:SellerComponent}
    ],
    // canActivate:[LoginGuard],
    // canDeactivate:[UnsavedGuard],
    resolve:{
      product:ProductResolve
    }
  },//预先定义参数的处理
  {path:'**',component:Code404Component}
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers:[LoginGuard,UnsavedGuard,ProductResolve]
})
export class AppRoutingModule { }
